set more 1

/*
File:	cepr_org_idvar.do
Date:	Nov 14, 2005, CEPR ORG Version 1.0
	Mar 12, 2015, CEPR ORG Version 2.0
	Apr  1, 2015, CEPR ORG Version 2.0.1
	March 1, 2016, CEPR ORG Version 2.1
	Oct 12, 2016, CEPR ORG Version 2.1.1
	Feb 9, 2017, CEPR ORG Version 2.2
	Apr 21, 2017, CEPR ORG Version 2.2.1
	Apr 10, 2018, CEPR ORG Version 2.3
	Mar 22, 2019, CEPR ORG Version 2.4
	Jul 24, 2019, CEPR ORG Version 2.4.1
	Feb 05, 2020, CEPR ORG Version 2.5
	
Desc:	Creates consistent household and personal identifiers and weights
	for CEPR consistent extract of CPS ORG
Note:	See copyright notice at end of program.
*/

/* Determine data year */
local year=year in 1
if `year'==-17345 {local year  = 1980}
di "`year'"

lab var year "Year"
notes year: CPS: h-year

/* Month of interview */
rename intmonth month
lab var month "Month"
notes month: CPS: h-month, hrmonth

/* Month in sample */
lab var minsamp "Month in sample"
notes minsamp: ORG consists of months 4 and 8 only
notes minsamp: CPS: h-mis, hrmis

/* hhid */
lab var hhid "Household ID"
notes hhid: Unique to address, not household 
notes hhid: CPS: h-id, hrhid

/* hhid2 */
gen byte hhid2=.
lab var hhid2 "Household ID Part 2"
notes hhid2: Unique to address, not household
notes hhid2: Available Aug 2005- only
notes hhid2: From May 2004-, concatenate hhid2 with hhid to uniquely identify HH
notes hhid2: CPS: hrhhid2

/* hrsample */
if 1979<=`year' & `year'<=1993 {
gen byte hrsample=.
}
lab var hrsample "Household sample ID"
notes hrsample: Available 1994- only

/* hrsersuf */

gen byte hrsersuf=.
lab var hrsersuf "Household serial suffix"
notes hrsersuf: Use to differentiate HH with same hhid
notes hrsersuf: Available 1994- only

/* hhnum */
lab var hhnum "Household counter"
notes hhnum: Increments by 1 for each new household at hhid address 
notes hhnum: CPS: h-hhnum, huhhnum

/* hrlonglk  */
if 1979<=`year' & `year'<=1993 {
gen hrlonglk=.
}
lab var hrlonglk "Longitudinal link"
lab def link 0 "Replacement" 2 "Continuing"
lab val hrlonglk link
notes hrlonglk: Longitudinal link is month-to-month, not year to year
notes hrlonglk: Available 1994-on
notes hrlonglk: CPS: hrlonglk

/* lineno */
lab var lineno "Person number"
notes lineno: Person line number within household
notes lineno: CPS: a-lineno, pulineno

/* Weights */

rename weight fnlwgt
lab var fnlwgt "Final weight"
notes fnlwgt: CPS: a_fnlwgt, pwsswgt

rename earnwt orgwgt
lab var orgwgt "Earnings weight"
notes orgwgt: Sum to civilian, non-institutional population in each month
notes orgwgt: To obtain approximate US population with full year of data, /*
*/ divide orgwgt by 12
notes orgwgt: CPS: a-ernlwt, pworwgt

gen byte lonwgt=.
lab var lonwgt "Longitudinal weight"
notes lonwgt: Only for adult records matched across CPS from month to month
notes lonwgt: Used for gross flow analysis
notes lonwgt: Available 1994-on
notes lonwgt: CPS: pwlgwgt

gen byte famwgt=.
lab var famwgt "Family weight"
notes famwgt: Only for tallying family characteristics
notes famwgt: Sum to civilian, non-institutional population in each month
notes famwgt: To obtain approximate US population with full year of data, /*
*/ divide orgwgt by 12
notes famwgt: Available 1994-on
notes famwgt: CPS: pwfmwgt
/* 
Copyright 2020 CEPR and John Schmitt

This file is part of the cepr_org_master.do program. This file and all
programs referenced in it are free software. You can redistribute the
program or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
USA.
*/
